<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8" %>
<%@ include file="/taglibs.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>
    <%@ include file="/uilibs.jsp" %>
    <script src="${res}/js/md5.js" type="text/javascript"></script>
</head>

<body>

<style type="text/css">
body
{
    width:100%;height:100%;margin:0;overflow:hidden;
}
</style>

<div id="loginWindow" class="mini-window" title="用户登录" style="width:300px;height:165px;" 
   showModal="true" showCloseButton="false"
    >

    <div id="loginForm" style="padding:15px;padding-top:10px;">
        <table >
            <tr>
                <td style="width:60px;"><label for="username$text">帐号：</label></td>
                <td>
                    <input id="username" name="username" class="mini-textbox" required="true" style="width:150px;"/>
                </td>    
            </tr>
            <tr>
                <td style="width:60px;"><label for="pwd$text">密码：</label></td>
                <td>
                    <input id="password" name="password" class="mini-password" requiredErrorText="密码不能为空" required="true" style="width:150px;" onenter="onLoginClick"/>
                </td>
            </tr>
            <tr>
                <td></td>
                <td style="padding-top:5px;">
                    <a onclick="onLoginClick" class="mini-button" style="width:60px;">登录</a>
                    <a onclick="onResetClick" class="mini-button" style="width:60px;">重置</a>
                </td>
            </tr>
        </table>
    </div>

</div>

<script type="text/javascript">
mini.parse();

var loginWindow = mini.get("loginWindow");
loginWindow.show();

var loading;
function onLoginClick(e) {
    var form = new mini.Form("#loginWindow");

    form.validate();
    if (form.isValid() == false) return;

    loginWindow.hide();
    
    loading = mini.loading("正在登录系统，请稍后...", "登录系统");
    $.post("${ctx}/system/main/validate",{username:mini.get("username").getValue(),password:hex_md5(mini.get("password").getValue())},function(data){
        if(data){
            location.href="${ctx}/system/main/frame";
        } else {
            mini.hideMessageBox(loading);
            mini.alert("用户名或密码错误！","",function(){
            	loginWindow.show();
            });
        }
    },"json");

}
function onResetClick(e) {
    var form = new mini.Form("#loginWindow");
    form.clear();
}

</script>
</body>

</html>